Skip to content

feat(bump): added support for running arbitrary hooks during bump#644

Merged
Lee-W merged 3 commits intocommitizen-tools:masterfrom
skoef:add-hooks-for-bump-command
Feb 8, 2023
Merged

feat(bump): added support for running arbitrary hooks during bump#644
Lee-W merged 3 commits intocommitizen-tools:masterfrom
skoef:add-hooks-for-bump-command

Conversation

@skoef
Copy link
Contributor

@skoef skoef commented Dec 21, 2022

Description

To make commitizen integrate even better, new configuration keys hooks_pre_bump and hooks_post_bump were added to allow to run arbitrary commands prior to and right after running bump.

I've backported the work done by @janw and slightly adjusted it:

  • updated the patch to apply against the latest version of commitizen
  • run hooks_pre_bump hooks after the versions have been updated but before they are committed and tagged, so additional documentation can be generated with the new version or other generators can be run and staged.
  • I couldn't think of a usecase why you would want to hook into the process of generating the changelog so I completely removed this part.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Steps to Test This Pull Request

  1. Add something like this in your commitizen config file:
[tool.commitizen]
hooks_pre_bump = [
  "touch foo.bar",
  "git add foo.bar"
]
  1. Run cz bump and notice the Running hook output
  2. Run git show HEAD to see foo.bar is part of the latest release

Additional context

Closes: #292
Thanks to @janw to do the heavy lifting here.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to run arbitrary hooks pre/post version bump

4 participants